package com.openingedu.mba.screen.activity.practice;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.lurencun.android.support.ui.BackUIActivity;
import com.lurencun.android.support.widget.CommonAdapter;
import com.openingedu.mba.R;
import com.openingedu.mba.common.AppSetting;
import com.openingedu.mba.persist.DbHistory;
import com.openingedu.mba.persist.DbMessage;
import com.openingedu.mba.screen.adapter.HistoryAdapter;
import com.openingedu.mba.service.PracticeService;

/**
 * 
 * 练习历史记录
 * @author unidw
 *
 */
public class HistoryActivity extends BackUIActivity {

	private Context mContext;
	private PracticeService practiceService;
	private ListView listView;
	private List<DbHistory> historyList;
	private CommonAdapter<DbHistory> historyAdapter;
	private String title;
	
	@Override
	protected void onCreateEx(Bundle savedInstanceState) {
		mContext = this;
		practiceService = new PracticeService();
		Intent intent = getIntent();
		title = intent.getStringExtra(AppSetting.MENU_TITLE);
		// 设置标题
		TextView titleView = (TextView) findViewById(R.id.app_title);
		titleView.setText(title);
		listView = (ListView) findViewById(R.id.list_container);
		historyAdapter = new HistoryAdapter(mContext);
		historyList = practiceService.listHistory(mContext);
		historyAdapter.updateDataCache(historyList);
		listView.setAdapter(historyAdapter);
	}
	
	@Override
	protected int getBackButtonResId() {
		return R.id.back_button;
	}

	@Override
	protected int getContentViewLayoutId() {
		return R.layout.practice_history;
	}

	@Override
	protected boolean isConfirmBack() {
		return false;
	}

}
